package rmaqlc31.basic;

public class J11_Rectangle {

	public static void main(String[] args) {
		Rectangle r = new Rectangle();
		Rectangle s = new Rectangle(1,1,2,3);
		
		r.show();
		s.show();
		System.out.println("사각형 넓이 : "+s.square());
		r.set(-2,2,-1,4);
		r.show();
		System.out.println("사각형 넓이 : "+r.square());
		if(r.equals(s))
			System.out.println("두 사격형은 같습니다.");
		
	}

}

class Rectangle {
	int x1;
	int y1;
	int x2;
	int y2;
	int square;
	
	public Rectangle() {}
	public Rectangle(int x1, int y1, int x2, int y2) {
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
	}
	void set(int x1, int y1, int x2, int y2) {
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
	}
	int square() {
		square = (x2-x1)*(y2-y1);
		return square;
	}
	void show() {
		System.out.println("x1 : "+x1);
		System.out.println("x2 : "+x2);
		System.out.println("y1 : "+y1);
		System.out.println("y2 : "+y2);
	}
	boolean equals(Rectangle r) {
		if(square==r.square){
		return true;
		}
		else
			return false;
	}
}

